<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>会员中心</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="author" content="夜读书">
    <meta name="description" content="夜读书中文网">
    <meta name="keywords" content="读书,阅读,小说,文学">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="{{ asset('/bootstrap-3.3.5-dist/css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ asset('/style/css/yds.css') }}">
    <link rel="stylesheet" href="{{ asset('/style/css/ucenter.css') }}">
    <script src="{{ asset('/scripts/jquery/jquery-1.11.3.min.js') }}"></script>
    <script src="{{ asset('/bootstrap-3.3.5-dist/js/bootstrap.min.js') }}"></script>
</head>
<body>
@include('books.partials.navtop')
@include('books.partials.nav')
<div id="yds_screen">
<div id="yds_content" class="clearfix">
@include('ucenter.partials.adminmenu')
  <div class="spaceList adminbody">
    <div class="adminhead">
        <h1>修改个人资料</h1>
    </div>
    <div class="admincontent mainform">
        <form name="form" class="form-horizontal" method="post" action="">
        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
            <div class=""><span>信箱：</span><span>{{$users->email}}</span></div>
            <div class=""><span>昵称：</span><span>{{$users->user_name}}</span></div>
            <div class="">
                <span>性别：</span>
                <span><input name="sex" value="1" type="radio" @if($users->sex==1)checked="checked"@endif></input>男 <input name="sex" value="2" type="radio" @if($users->sex==2)checked="checked"@endif></input>女</span>
            </div>
            <div class="">
                <span>生日：</span>
                <span>
                    <select name="year">                    
                        <option value=""></option>                                       
                    </select>年
                    <select name="month">
                        <option value=""></option>                        
                    </select>月
                    <select name="day">
                        <option value=""></option>                        
                    </select>日
                </span>
            </div>
            <div class="">
                <span>现居：</span>
                <span>
                    <select style="display: inline-block;" name="province" class="province">
                    
                    </select>
                    <select style="display: inline-block;" name="city" class="city">
                    
                    </select>
                </span>
            </div>
            <div class="">
                <span>职业：</span>
                <span>
                    <select name="job_id">
                        <option value="0" >--</option>
                        @foreach($jobs as $job)
                        <option value="{{$job->id}}" @if($job->id == $users->job_id)selected=""@endif>{{$job->job_name}}</option>
                        @endforeach
                    </select>
                </span>
            </div>
            <div class="">
                <span>个性签名：</span>
                <span>
                    <input class="form-control" style="width:500px;" name="signature" maxlength="128" value="@if(!empty($usersattrib)){{$usersattrib->signature}}@endif" type="text"></input>
                </span>
            </div>
            <div class="">
                <span>书城介绍：</span>
                <span>
                    <input class="form-control" style="width:500px;" name="shopjieshao" maxlength="200" value="@if(!empty($usersattrib)){{$usersattrib->shopjieshao}}@endif" type="text"></input>
                </span>
            </div>
            <div class="">
                <span>联系QQ：</span>
                <span>
                    <input class="form-control" style="width:300px;" name="qq" maxlength="128" value="@if(!empty($usersattrib)){{$usersattrib->qq}}@endif" type="text"></input>
                </span>
            </div>
            <div class="">
                <span>手机号码：</span>
                <span>{{$users->mobile}}</span>
            </div>
            <div class="bton"><span class="ms"></span><button type="button" id="saveprofile" class="btn btn-success">保存</button></div>
        </form>
    </div>
  </div>
</div>
</div>
@include('books.partials.footer')
<script type="text/javascript">
//jquery省份城市选择器
var pro = ["请选择省份或直辖市","北京市","天津市","上海市","重庆市","河北省","山西省","辽宁省","吉林省","黑龙江省","江苏省","浙江省","安徽省","福建省","江西省","山东省","河南省","湖北省","湖南省","广东省","海南省","四川省","贵州省","云南省","陕西省","甘肃省","青海省","内蒙古自治区","广西壮族自治区","西藏自治区","宁夏回族自治区","新疆维吾尔自治区","香港","澳门","台湾"];
var city = {请选择省份或直辖市:["请选择城市"],北京市:["东城区","西城区","崇文区","宣武区","朝阳区","海淀区","丰台区","石景山区","房山区","通州区","顺义区","昌平区","大兴区","怀柔区","平谷区","门头沟区","密云县","延庆县"],天津市:["和平区","河东区","河西区","南开区","河北区","红桥区","东丽区","西青区","北辰区","津南区","武清区","宝坻区","滨海新区","静海县","宁河县","蓟县"],上海市:["黄浦区","卢湾区","徐汇区","长宁区","静安区","普陀区","闸北区","虹口区","杨浦区","闵行区","宝山区","嘉定区","浦东新区","金山区","松江区","青浦区","奉贤区","崇明县"],重庆市:["渝中区","大渡口区","江北区","南岸区","北碚区","渝北区","巴南区","长寿区","双桥区","沙坪坝区","万盛区","万州区","涪陵区","黔江区","永川区","合川区","江津区","九龙坡区","南川区","綦江县","潼南县","荣昌县","璧山县","大足县","铜梁县","梁平县","开县","忠县","城口县","垫江县","武隆县","丰都县","奉节县","云阳县","巫溪县","巫山县","石柱土家族自治县","秀山土家族苗族自治县","酉阳土家族苗族自治县","彭水苗族土家族自治县"],河北省:["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],山西省:["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],辽宁省:["沈阳","大连","鞍山","抚顺","本溪","丹东","锦州","营口","阜新","辽阳","盘锦","铁岭","朝阳","葫芦岛"],吉林省:["长春","吉林","四平","辽源","通化","白山","松原","白城","延边朝鲜族自治州"],黑龙江省:["哈尔滨","齐齐哈尔","鹤岗","双鸭山","鸡西","大庆","伊春","牡丹江","佳木斯","七台河","黑河","绥化","大兴安岭"],江苏省:["南京","苏州","无锡","常州","镇江","南通","泰州","扬州","盐城","连云港","徐州","淮安","宿迁"],浙江省:["杭州","宁波","温州","嘉兴","湖州","绍兴","金华","衢州","舟山","台州","丽水"],安徽省:["合肥","芜湖","蚌埠","淮南","马鞍山","淮北","铜陵","安庆","黄山","滁州","阜阳","宿州","巢湖","六安","亳州","池州","宣城"],福建省:["福州","厦门","莆田","三明","泉州","漳州","南平","龙岩","宁德"],江西省:["南昌","景德镇","萍乡","九江","新余","鹰潭","赣州","吉安","宜春","抚州","上饶"],山东省:["济南","青岛","淄博","枣庄","东营","烟台","潍坊","济宁","泰安","威海","日照","莱芜","临沂","德州","聊城","滨州","菏泽"],河南省:["郑州","开封","洛阳","平顶山","安阳","鹤壁","新乡","焦作","濮阳","许昌","漯河","三门峡","南阳","商丘","信阳","周口","驻马店"],湖北省:["武汉","黄石","十堰","荆州","宜昌","襄樊","鄂州","荆门","孝感","黄冈","咸宁","随州","恩施"],湖南省:["长沙","株洲","湘潭","衡阳","邵阳","岳阳","常德","张家界","益阳","郴州","永州","怀化","娄底","湘西"],广东省:["广州","深圳","珠海","汕头","韶关","佛山","江门","湛江","茂名","肇庆","惠州","梅州","汕尾","河源","阳江","清远","东莞","中山","潮州","揭阳","云浮"],海南省:["海口","三亚"],四川省:["成都","自贡","攀枝花","泸州","德阳","绵阳","广元","遂宁","内江","乐山","南充","眉山","宜宾","广安","达州","雅安","巴中","资阳","阿坝","甘孜","凉山"],贵州省:["贵阳","六盘水","遵义","安顺","铜仁","毕节","黔西南","黔东南","黔南"],云南省:["昆明","曲靖","玉溪","保山","昭通","丽江","普洱","临沧","德宏","怒江","迪庆","大理","楚雄","红河","文山","西双版纳"],陕西省:["西安","铜川","宝鸡","咸阳","渭南","延安","汉中","榆林","安康","商洛"],甘肃省:["兰州","嘉峪关","金昌","白银","天水","武威","酒泉","张掖","庆阳","平凉","定西","陇南","临夏","甘南"],青海省:["西宁","海东","海北","海南","黄南","果洛","玉树","海西"],内蒙古自治区:["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","锡林郭勒盟","兴安盟","阿拉善盟"],广西壮族自治区:["南宁","柳州","桂林","梧州","北海","防城港","钦州","贵港","玉林","百色","贺州","河池","来宾","崇左"],西藏自治区:["拉萨","那曲","昌都","林芝","山南","日喀则","阿里"],宁夏回族自治区:["银川","石嘴山","吴忠","固原","中卫"],新疆维吾尔自治区:["乌鲁木齐","克拉玛依","吐鲁番","哈密","和田","阿克苏","喀什","克孜勒苏","巴音郭楞","昌吉","博尔塔拉","伊犁","塔城","阿勒泰"],香港:["香港岛","九龙东","九龙西","新界东","新界西"],澳门:["澳门半岛","离岛"],台湾:["台北","高雄","基隆","新竹","台中","嘉义","台南市"]};
$(document).ready(function(){
for(var i=0;i<pro.length;i++){
$option=$("<option/>")
$option.attr("value",pro[i]);
if(pro[i] == "{{$users->province}}"){
$option.attr("selected","selected");
}
$option.text(pro[i]);
$(".province").append($option);
}
////////////////
$(".province").append(function(){
var cities=city[$(this).val()];
$(this).parent().find(".city").empty();
for(var j=0;j<cities.length;j++){
$option=$("<option/>")
$option.attr("value",cities[j]);
if(cities[j] == "{{$users->city}}"){
$option.attr("selected","selected");
}
$option.text(cities[j]);
$(this).parent().find(".city").append($option);
}
});
/////////////////////////
$(".province").click(function(){
var cities=city[$(this).val()];
$(this).parent().find(".city").empty();
for(var i=0;i<cities.length;i++){
$option=$("<option/>")
$option.attr("value",cities[i]);
if(cities[i] == "{{$users->city}}"){
$option.attr("selected","selected");
}
$option.text(cities[i]);
$(this).parent().find(".city").append($option);
}
});
});

//生成生日(年月日)级联菜单
    var date = new Date();
    year = date.getFullYear();//获取当前年份
    //var i= year-80; //60岁以内
    var i= 1900;
    var dropList;
    for(year;year>i;year--){
        if(year == {{$birthday[0]}}){
            dropList = dropList + "<option value='"+{{$birthday[0]}}+"' selected>"+{{$birthday[0]}}+"</option>";
        }else{
            dropList = dropList + "<option value='"+year+"'>"+year+"</option>";
        }
    }
    $('select[name=year]').html(dropList);//生成年份下拉菜单
    var monthly;
    for(month=1;month<13;month++){
        if(month == {{$birthday[1]}}){
            monthly = monthly + "<option value='"+{{$birthday[1]}}+"' selected>"+{{$birthday[1]}}+"</option>";
        }else{
            monthly = monthly + "<option value='"+month+"'>"+month+"</option>";
        }
    }
    $('select[name=month]').html(monthly);//生成月份下拉菜单
    var dayly;
    for(day=1;day<=31;day++){
        if(day == {{$birthday[2]}}){
            dayly = dayly + "<option value='"+{{$birthday[2]}}+"' selected>"+{{$birthday[2]}}+"</option>";
        }else{
            dayly = dayly + "<option value='"+day+"'>"+day+"</option>";
        }
    }
    $('select[name=day]').html(dayly);//生成天数下拉菜单
    /*
     * 处理每个月有多少天---联动
     */
    $('select[name=month]').change(function(){
        var currentDay;
        var Flag = $('select[name=year]').val();
        var currentMonth = $('select[name=month]').val();
        switch(currentMonth){
            case "1" :
            case "3" :
            case "5" :
            case "7" :
            case "8" :
            case "10" :
            case "12" :total = 31;break;
            case "4" :
            case "6" :
            case "9" :
            case "11" :total = 30;break;
            case "2" :
                if((Flag%4 == 0 && Flag%100 != 0) || Flag%400 == 0){
                    total = 29;
                }else{
                    total = 28;
                }
            default:break;
        }
        for(day=1;day <= total;day++){
            currentDay = currentDay + "<option value='"+day+"'>"+day+"</option>";
        }
        $('select[name=day]').html(currentDay);//生成日期下拉菜单
        })
</script>
<script>
$(document).ready(function(){
    $("#saveprofile").click(function (){
            $.ajax({
                type: 'post',   // 路由器中提交页面使用post方式，这里也需要用post
                url: '{{url('u/admin/saveprofile')}}',       //返回内容，成功返回OK                
                dataType: 'text',
                data: $("form").serialize(),                
                success: function (msg) {
                    if (msg == "ok"){
                        $(".ms").html("<span class='msinfo'><font color='red'>资料保存成功!</font></span>");
                        $(".msinfo").fadeOut(3000);
                        return false;  
                    }else{                          
                        $(".ms").html("<span class='msinfo'><font color='red'>错误提示</font></span>");
                        $(".msinfo").fadeOut(3000);
                        return false;                      
                    }
                }
            });
    });
});
</script>
</body>
</html>
